/*
 * ChannelInterface.h
 *
 */

#ifndef CHANNELINTERFACE_H_
#define CHANNELINTERFACE_H_

#include <iostream>
#include "../IPC/MessageQueue.h"
#include "ChannelCommon.h"

namespace channel {

class ChannelInterface {
private:
	ipc::MessageQueue<channel::ChannelMessage> m_queue;
	std::string m_hostName;
public:

	typedef enum{SENDER=0,RECEIVER}InterfaceType;

	ChannelInterface(InterfaceType tipo,std::string hostName);

    /**
     * Destructor
     */
    virtual ~ChannelInterface();

    /**
     */
    void send(int destino,char *payload ,size_t size);

    /**
     */
    void recv(int mType,char *payload ,size_t size);

    /**
     */
    void recv(std::string receiver,char *payload ,size_t size);

    /**
     *
     */
    void getFromQueue(channel::ChannelMessage &message);

    /**
     *
     */
    void putInQueue(channel::ChannelMessage &message);

    /**
     *
     */
    static void disconnectChannel(std::string hostName);

    /**
     */
    static void create(std::string hostName);

    /**
     */
    static void destroy(std::string hostName);

private:
	static const std::string CHANNEL_INTERFACE_PATH;

	static const char CHANNEL_INTERFACE_SEND_KEY = 'a';
	static const char CHANNEL_INTERFACE_RECEIVE_KEY = 'b';
};

} /* namespace channel */
#endif /* CHANNELINTERFACE_H_ */
